package com.java.service.impl;

import com.java.dao.UserMapper;
import com.java.model.Admin;
import com.java.model.Media;
import com.java.model.Result;
import com.java.model.User;
import com.java.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import javax.servlet.http.HttpServletRequest;


@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Override
    public Result login(Media media, HttpServletRequest request, Model model) {
        Media use = userMapper.login(media);
        if (use!=null){
            request.getSession().setAttribute("user",use);
            model.addAttribute("user",media);
            return Result.success();
        }
        return Result.error("用户名或密码错误");
    }


}
